#include "logindialog.h"

#include <QComboBox>
#include <QGroupBox>
#include <QRadioButton>
#include <QPainter>
#include <QStyleOption>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFormLayout>

LoginDialog::LoginDialog():
    m_pLogInButton(new QPushButton(tr("Login"))),
    m_pNameLineEdit(new QLineEdit),
    m_pPWDLineEdit(new QLineEdit),
    m_pPromptLabel(new QLabel)
{
    resize(400,150);
    setObjectName("LoginDialog");

    m_pLogInButton->setObjectName("m_pLogInButton");
    m_pNameLineEdit->setObjectName("m_pNameLineEdit");
    m_pPWDLineEdit->setObjectName("m_pPWDLineEdit");
    m_pPromptLabel->setObjectName("m_pPromptLabel");

    m_pLogInButton->setFixedSize(60,60);

    QLabel *nameLabel=new QLabel(tr("Name:"));
    nameLabel->setObjectName("nameLabel");
    QLabel*passWDLabel=new QLabel(tr("PassWord:"));
    passWDLabel->setObjectName("passWDLabel");

    QFormLayout *formLayout=new QFormLayout;
    formLayout->addWidget(new QLabel);
    formLayout->addRow(nameLabel,m_pNameLineEdit);
    formLayout->addRow(passWDLabel,m_pPWDLineEdit);
    formLayout->addWidget(m_pPromptLabel);

    QHBoxLayout *nameHLayout=new QHBoxLayout;
    nameHLayout->addStretch(1);
    nameHLayout->addLayout(formLayout);
    nameHLayout->addWidget(m_pLogInButton);
    nameHLayout->addStretch(1);

    QVBoxLayout *layout=new QVBoxLayout;
    layout->addStretch(1);
    //    layout->addWidget(m_pPromptLabel);
    layout->addLayout(nameHLayout);
    layout->addStretch(1);

    setLayout(layout);

    m_pPromptLabel->setText("User name not exist.");

    //connect
    connect(m_pLogInButton,SIGNAL(pressed()),
            this,SLOT(slotLogin()));
}

LoginDialog::~LoginDialog()
{

}

void LoginDialog::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);

    QStyleOption opt;
    opt.init(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

void LoginDialog::slotLogin()
{

}

PreviewSpeedDialog::PreviewSpeedDialog():
    m_pLowButton(new QRadioButton(tr("Low"))),
    m_pMidButton(new QRadioButton(tr("Mid"))),
    m_pHighButton(new QRadioButton(tr("High"))),
    m_pOkButton(new QPushButton(tr("OK")))
{
    setObjectName("PreviewSpeedDialog");
    resize(450,200);

    m_pLowButton->setObjectName("m_pLowButton");
    m_pMidButton->setObjectName("m_pMidButton");
    m_pHighButton->setObjectName("m_pHighButton");
    m_pOkButton->setObjectName("m_pOkButton");

    QVBoxLayout *lowRadioLayout=new QVBoxLayout;
    lowRadioLayout->addWidget(m_pLowButton);
    lowRadioLayout->addWidget(m_pMidButton);
    lowRadioLayout->addWidget(m_pHighButton);

    QGroupBox *subGroupBox=new QGroupBox;
    subGroupBox->setObjectName("subGroupBox");
    subGroupBox->setLayout(lowRadioLayout);

    QLabel *previewLabel=new QLabel(tr("Preview Speed:"));
    previewLabel->setObjectName("previewLabel");
    QHBoxLayout *labelHLayout=new QHBoxLayout;
    labelHLayout->addWidget(previewLabel);
    labelHLayout->addWidget(subGroupBox);

    QVBoxLayout *buttonVLayout=new QVBoxLayout;
    buttonVLayout->addLayout(labelHLayout);
    buttonVLayout->addWidget(m_pOkButton,0,Qt::AlignRight);

    QGroupBox *groupBox=new QGroupBox;
    groupBox->setObjectName("groupBox");
    groupBox->setTitle(tr("Preview"));
    groupBox->setLayout(buttonVLayout);

    QHBoxLayout *layout=new QHBoxLayout;
    layout->addWidget(groupBox);

    setLayout(layout);
}

PreviewSpeedDialog::~PreviewSpeedDialog()
{
}


ParamSettingsDialog::ParamSettingsDialog():
    m_pStretchComboBox(new QComboBox),
    m_pOkButton(new QPushButton(tr("OK"))),
    m_pResolutionComboBox(new QComboBox),
    m_pRevolveComboBox(new QComboBox)
{
    setObjectName("ParamSettingsDialog");
    resize(350,220);

    m_pStretchComboBox->setObjectName("m_pStretchComboBox");
    m_pOkButton->setObjectName("m_pOkButton");
    m_pResolutionComboBox->setObjectName("m_pResolutionComboBox");
    m_pRevolveComboBox->setObjectName("m_pRevolveComboBox");

    QLabel *stretchLabel=new QLabel(tr("Stretch type:"));
    stretchLabel->setObjectName("stretchLabel");
    QLabel *angleLabel=new QLabel(tr("Angle of rotation:"));
    angleLabel->setObjectName("angleLabel");
    QLabel *resolutionLabel=new QLabel(tr("Resolution:"));
    resolutionLabel->setObjectName("resolutionLabel");

    QFormLayout *formLayout=new QFormLayout;
    formLayout->addRow(stretchLabel,m_pStretchComboBox);
    formLayout->addRow(angleLabel,m_pRevolveComboBox);
    formLayout->addRow(resolutionLabel,m_pResolutionComboBox);

    QVBoxLayout *formVLayout=new QVBoxLayout;
    formVLayout->addLayout(formLayout);
    formVLayout->addWidget(m_pOkButton,0,Qt::AlignRight);

    QGroupBox *groupBox=new QGroupBox;
    groupBox->setObjectName("groupBox");
    groupBox->setTitle(tr("Parameter"));
    groupBox->setLayout(formVLayout);

    QHBoxLayout *layout=new QHBoxLayout;
    layout->addWidget(groupBox);

    setLayout(layout);
}

ParamSettingsDialog::~ParamSettingsDialog()
{

}
